package com.bx.implatform.growUp.config;

import com.bx.implatform.growUp.interceptor.GrowUpHeaderInterceptor;
import jakarta.annotation.Resource;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.client.RestTemplate;

@Configuration
public class GrowUpRestTemplateConfig {

    @Resource
    GrowUpProperties growUpProperties;

    @Bean("growUpRestTemplate")
    public RestTemplate growUpRestTemplate() {
        RestTemplate restTemplate = new RestTemplate();
        // 添加签名拦截器（从配置读取appKey和secretKey）
        restTemplate.getInterceptors().add(new GrowUpHeaderInterceptor(growUpProperties.getClientId(), growUpProperties.getAccessToken()));
        return restTemplate;
    }
}
